import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import '../ui/base_scaffold.dart';

class YlmGlobalConfig {
  YlmGlobalConfig._init();

  static final YlmGlobalConfig _instance = YlmGlobalConfig._init();

  factory YlmGlobalConfig() => _instance;

  late YlmGlobalActionSheetGlobalConfig actionSheetConfig;

  late YlmGlobalAppBarConfig appBarConfig;

  late YlmGlobalPhotoPickerConfig assetPickerConfig;

  late YlmGlobalPermissionConfig permissionConfig;

  late YlmGlobalLoadingConfig loadingConfig;

  void init({
    YlmGlobalActionSheetGlobalConfig? actionSheetConfig,
    YlmGlobalAppBarConfig? appBarConfig,
    YlmGlobalPhotoPickerConfig? assetPickerConfig,
    YlmGlobalPermissionConfig? permissionConfig,
    YlmGlobalLoadingConfig? loadingConfig,
  }) {
    this.actionSheetConfig = actionSheetConfig ??= YlmGlobalActionSheetGlobalConfig();
    this.appBarConfig = appBarConfig ??= YlmGlobalAppBarConfig();
    this.assetPickerConfig = assetPickerConfig ??= YlmGlobalPhotoPickerConfig();
    this.permissionConfig = permissionConfig ??= YlmGlobalPermissionConfig();
    this.loadingConfig = loadingConfig ??= YlmGlobalLoadingConfig();
  }
}

class YlmGlobalAppBarConfig {
  final Widget? leading;
  final SystemUiOverlayStyle statusBarStyle;

  YlmGlobalAppBarConfig({this.leading, this.statusBarStyle = MainStatusBar.dark});
}

class YlmGlobalActionSheetGlobalConfig {
  final String cancelTitle;
  final String confirmTitle;

  YlmGlobalActionSheetGlobalConfig({this.cancelTitle = '取消', this.confirmTitle = '确定'});
}

class YlmGlobalPhotoPickerConfig {
  final Color? themeColor;

  YlmGlobalPhotoPickerConfig({this.themeColor});
}

class YlmGlobalLoadingConfig {
  final Color color;

  YlmGlobalLoadingConfig({this.color = Colors.white});
}

class YlmGlobalPermissionConfig {
  final String photoTitle;
  final String photoMessage;
  final String cameraTitle;
  final String cameraMessage;
  final String microphoneTitle;
  final String microphoneMessage;
  final String storageTitle;
  final String storageMessage;
  final String cancelTitle;
  final String confirmTitle;

  YlmGlobalPermissionConfig({
    this.photoTitle = '需要授权',
    this.photoMessage = '无法访问相册',
    this.cameraTitle = '需要授权',
    this.cameraMessage = '无法访问相机',
    this.microphoneTitle = '需要授权',
    this.microphoneMessage = '无法访问麦克风',
    this.storageTitle = '需要授权',
    this.storageMessage = '无法访问文件存储',
    this.cancelTitle = '取消',
    this.confirmTitle = '确定',
  });
}
